home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
metkit
/
discat.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-06-07
|
3KB
|
98 lines
// Copyright (C) 1996, 1997 Meta Four Software. All rights reserved.
//
// Disk catalog sample code
//
//! rev="$Id: discat.cpp,v 1.3 1997/05/27 00:06:36 jcw Rel $"
#include "stdafx.h"
#include "discat.h"
#include "catalog.h"
CMyApp ThisApp; // the global application object
/////////////////////////////////////////////////////////////////////////////
// CMyApp
BOOL CMyApp::InitInstance()
{
CMainDlgWindow mainDlg;
m_pMainWnd = &mainDlg;
mainDlg.DoModal();
return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainDlgWindow
BEGIN_MESSAGE_MAP(CMainDlgWindow, CDialog)
//{{AFX_MSG_MAP(CMainDlgWindow)
ON_BN_CLICKED(IDC_SCAN_BTN, OnScanBtn)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
CMainDlgWindow::CMainDlgWindow()
: CDialog (CMainDlgWindow::IDD)
{
//{{AFX_DATA_INIT(CMainDlgWindow)
//}}AFX_DATA_INIT
}
void CMainDlgWindow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMainDlgWindow)
DDX_Control(pDX, IDC_PATH, m_path);
DDX_Control(pDX, IDC_STATUS, m_status);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
// [JCW] This code added for MetaKit DISCAT
BOOL CMainDlgWindow::OnInitDialog()
{
CDialog::OnInitDialog();
// use the application directory as the default scan path
CString appDir = ThisApp.m_pszHelpFilePath;
int n = appDir.ReverseFind('\\');
if (n >= 0)
m_path.SetWindowText(appDir.Left(n));
return TRUE; // return TRUE unless you set the focus to a control
}
void CMainDlgWindow::OnScanBtn()
{
// find out which directory we should scan
CString path;
m_path.GetWindowText(path);
if (path.Right(1) == '\\')
path = path.Left(path.GetLength() - 1);
// indicate what is going on
m_status.SetWindowText("Scanning, please wait...");
// scan the directory tree, see CATALOG.CPP
c4_View dirs = fScanDirectories(path);
// show what happened
char buf [30];
wsprintf(buf, "%d directories were scanned.", dirs.GetSize());
m_status.SetWindowText(buf);
// save results to file
CFileDialog dlg (FALSE, NULL, "dirs");
if (dlg.DoModal() == IDOK)
{
c4_Storage storage (dlg.GetPathName(), true);
storage.Store("dirs", dirs);
storage.Commit();
}
}
/////////////////////////////////////////////////////////////////////////////